<?php
/*
 * @author GuoLong
 * @time 2014-12-09
 * @email guolong@howdo.cc
 */
class sysfeedback extends Model{

	var $table = "xdf_sysfeedback";
	var $fields = array('id','user_id','content','create_time');
	
	/**
	 * 设置-提交系统反馈
	 */
	public function addSysFeedback($user_id,$suggestedContent,$phone,$email){
		$sql = "INSERT INTO `$this->table` (`user_id`,`content`,`create_time`,`phone`,`email`) VALUES ('$user_id','$suggestedContent',NOW(),$phone,$email)";
		return $this->insert($sql);
	}
	public function getSysFeedbackList($user_id,$timestamp,$pagesize,$action){

		// 		if($action=='pre')//刷新
		$preOrMore_sql="";
		if($action=='more'){//获取更多
			$preOrMore_sql="AND id < $timestamp";
		}

		$sql="SELECT `id` as sysfeedback_id,content as content,create_time as create_time,phone,email
				FROM $this->table 
				WHERE `user_id`='$user_id' $preOrMore_sql ORDER BY id DESC LIMIT $pagesize;";
		// 		var_dump($sql);
		$data= $this->fetchAll( $sql );
		return $data;
	}
	public function getMySysFeedback($user_id,$sysfeedback_id){
		$sql="SELECT `id` as sysfeedback_id,content as content,create_time as create_time,phone,email
				FROM $this->table 
				WHERE `user_id`='$user_id' AND id=$sysfeedback_id";
		// 		var_dump($sql);
		$data= $this->fetchRow( $sql );
		return $data;
	}
}

